home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Utilities / Type1Manager / src / myfontstruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-12  |  7.0 KB  |  257 lines

  1. /*
  2.  * For the definition of struct GlyphMap,
  3.  */
  4. #include <diskfont/glyph.h>
  5.  
  6.  
  7. #ifdef MEMTRACE
  8. #define xalloc(n) (Xalloc((int)n, __FILE__, __FUNC__, __LINE__))
  9. #define xfree(p) (Xfree((char *)p, __FILE__, __FUNC__, __LINE__))
  10. #else
  11. #define xalloc(n) Xalloc ((int) n)
  12. #define xfree(p) Xfree ((char *) p)
  13. #endif
  14.  
  15.  
  16. /**
  17.  * fontmisc.h
  18.  **/
  19. typedef unsigned char *pointer;
  20. typedef int Bool;
  21.  
  22.  
  23. /**
  24.  * Xmd.h Xprotostr.h Xproto.h
  25.  **/
  26.  
  27. /*****************************************************************
  28.  * Structure Defns
  29.  *   Structures needed for replies
  30.  *****************************************************************/
  31. typedef struct {
  32.     short leftSideBearing;
  33.     short rightSideBearing;
  34.     short characterWidth;
  35.     short ascent;
  36.     short descent;
  37.     unsigned short attributes;
  38. } xCharInfo;
  39.  
  40.  
  41. /**
  42.  * fsmasks.h
  43.  **/
  44.  
  45. /* font format macros */
  46. #define BitmapFormatByteOrderMask       (1L << 0)
  47. #define BitmapFormatBitOrderMask        (1L << 1)
  48. #define BitmapFormatImageRectMask       (3L << 2)
  49. #define BitmapFormatScanlinePadMask     (3L << 8)
  50. #define BitmapFormatScanlineUnitMask    (3L << 12)
  51.  
  52. #define BitmapFormatByteOrderLSB        (0)
  53. #define BitmapFormatByteOrderMSB        (1L << 0)
  54. #define BitmapFormatBitOrderLSB         (0)
  55. #define BitmapFormatBitOrderMSB         (1L << 1)
  56.  
  57. #define BitmapFormatImageRectMin        (0L << 2)
  58. #define BitmapFormatImageRectMaxWidth   (1L << 2)
  59. #define BitmapFormatImageRectMax        (2L << 2)
  60.  
  61. #define BitmapFormatScanlinePad8        (0L << 8)
  62. #define BitmapFormatScanlinePad16       (1L << 8)
  63. #define BitmapFormatScanlinePad32       (2L << 8)
  64. #define BitmapFormatScanlinePad64       (3L << 8)
  65.  
  66. #define BitmapFormatScanlineUnit8       (0L << 12)
  67. #define BitmapFormatScanlineUnit16      (1L << 12)
  68. #define BitmapFormatScanlineUnit32      (2L << 12)
  69. #define BitmapFormatScanlineUnit64      (3L << 12)
  70.  
  71. #define BitmapFormatMaskByte            (1L << 0)
  72. #define BitmapFormatMaskBit             (1L << 1)
  73. #define BitmapFormatMaskImageRectangle  (1L << 2)
  74. #define BitmapFormatMaskScanLinePad     (1L << 3)
  75. #define BitmapFormatMaskScanLineUnit    (1L << 4)
  76.  
  77. typedef unsigned long  fsBitmapFormat;
  78. typedef unsigned long  fsBitmapFormatMask;
  79.  
  80.  
  81. /**
  82.  * font.h
  83.  **/
  84. /* data structures */
  85. typedef struct _Font *FontPtr;
  86. typedef struct _FontInfo *FontInfoPtr;
  87. typedef struct _FontPathElement *FontPathElementPtr;
  88. typedef struct _CharInfo *CharInfoPtr;
  89.  
  90.  /* draw direction */
  91. #define LeftToRight 0
  92. #define RightToLeft 1
  93. #define BottomToTop 2
  94. #define TopToBottom 3
  95.  
  96. #define NO_SUCH_CHAR    -1
  97.  
  98.  
  99. #define    AllocError    80
  100. #define    StillWorking    81
  101. #define    FontNameAlias    82
  102. #define    BadFontName    83
  103. #define    Suspended    84
  104. #define    Successful    85
  105. #define    BadFontPath    86
  106. #define    BadCharRange    87
  107. #define    BadFontFormat    88
  108. #define    FPEResetFailed    89    /* for when an FPE reset won't work */
  109.  
  110. /* OpenFont flags */
  111. #define FontLoadInfo    0x0001
  112. #define FontLoadProps    0x0002
  113. #define FontLoadMetrics    0x0004
  114. #define FontLoadBitmaps    0x0008
  115. #define FontLoadAll    0x000f
  116. #define    FontOpenSync    0x0010
  117.  
  118. /* Query flags */
  119. #define    LoadAll        0x1
  120. #define    FinishRamge    0x2
  121. #define EightBitFont    0x4
  122. #define SixteenBitFont  0x8
  123.  
  124.  
  125. /**
  126.  * fontstruct.h
  127.  **/
  128. /*
  129.  * This version of the server font data structure is only for describing
  130.  * the in memory data structure. The file structure is not necessarily a
  131.  * copy of this. That is up to the compiler and the OS layer font loading
  132.  * machinery.
  133.  */
  134.  
  135. typedef enum {
  136.     Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
  137. }           FontEncoding;
  138.  
  139. typedef struct _CharInfo {
  140.     xCharInfo   metrics;    /* info preformatted for Queries */
  141.     char       *bits;        /* pointer to glyph image */
  142.  
  143.     /***
  144.      * THE FOLLOWING WAS ADDED 5/13/93 BY AMISH S. DAVE
  145.      ***/
  146.     struct GlyphMap *glyphmap;    /* pointer to Amiga's struct GlyphMap */
  147.                 /* defined in <diskfont/glyph.h>      */
  148. }           CharInfoRec;
  149.  
  150.  
  151. /*
  152.  * Font is created at font load time. It is specific to a single encoding.
  153.  * e.g. not all of the glyphs in a font may be part of a single encoding.
  154.  */
  155.  
  156. typedef struct _FontInfo {
  157.     unsigned short firstCol;
  158.     unsigned short lastCol;
  159.     unsigned short firstRow;
  160.     unsigned short lastRow;
  161.     unsigned short defaultCh;
  162.     unsigned int noOverlap:1;
  163.     unsigned int terminalFont:1;
  164.     unsigned int constantMetrics:1;
  165.     unsigned int constantWidth:1;
  166.     unsigned int inkInside:1;
  167.     unsigned int inkMetrics:1;
  168.     unsigned int allExist:1;
  169.     unsigned int drawDirection:2;
  170.     unsigned int cachable:1;
  171.     unsigned int anamorphic:1;
  172.     short       maxOverlap;
  173.     short       pad;
  174.     xCharInfo   maxbounds;
  175.     xCharInfo   minbounds;
  176.     xCharInfo   ink_maxbounds;
  177.     xCharInfo   ink_minbounds;
  178.     short       fontAscent;
  179.     short       fontDescent;
  180.     int         nprops;
  181. }           FontInfoRec;
  182.  
  183. typedef struct _Font {
  184.     int         refcnt;
  185.     FontInfoRec info;
  186.     char        bit;
  187.     char        byte;
  188.     char        glyph;
  189.     char        scan;
  190.     fsBitmapFormat format;
  191.     int         (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */ );
  192.     int         (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */ );
  193.     void        (*unload_font) ( /* font */ );
  194.     FontPathElementPtr fpe;
  195.     pointer     svrPrivate;
  196.     pointer     fontPrivate;
  197.     pointer     fpePrivate;
  198.     int        maxPrivate;
  199.     pointer    *devPrivates;
  200. }           FontRec;
  201.  
  202.  
  203. /* External view of font paths */
  204. typedef struct _FontPathElement {
  205.     int         name_length;
  206.     char       *name;
  207.     int         type;
  208.     int         refcount;
  209.     pointer     private;
  210. }           FontPathElementRec;
  211.  
  212.  
  213. /*
  214.  * Various macros for computing values based on contents of
  215.  * the above structures
  216.  */
  217.  
  218. #define    GLYPHWIDTHPIXELS(pci) \
  219.     ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
  220.  
  221. #define    GLYPHHEIGHTPIXELS(pci) \
  222.      ((pci)->metrics.ascent + (pci)->metrics.descent)
  223.  
  224. #define    GLYPHWIDTHBYTES(pci)    (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
  225.  
  226. #define GLYPHWIDTHPADDED(bc)    (((bc)+7) & ~0x7)
  227.  
  228. #define BYTES_PER_ROW(bits, nbytes) \
  229.     ((nbytes) == 1 ? (((bits)+7)>>3)    /* pad to 1 byte */ \
  230.     :(nbytes) == 2 ? ((((bits)+15)>>3)&~1)    /* pad to 2 bytes */ \
  231.     :(nbytes) == 4 ? ((((bits)+31)>>3)&~3)    /* pad to 4 bytes */ \
  232.     :(nbytes) == 8 ? ((((bits)+63)>>3)&~7)    /* pad to 8 bytes */ \
  233.     : 0)
  234.  
  235. #define BYTES_FOR_GLYPH(ci,pad)    (GLYPHHEIGHTPIXELS(ci) * \
  236.                  BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
  237.  
  238. /*
  239.  * Macros for computing different bounding boxes for fonts; from
  240.  * the font protocol
  241.  */
  242.  
  243. #define FONT_MAX_ASCENT(pi)    ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
  244.                 (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
  245. #define FONT_MAX_DESCENT(pi)    ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
  246.                 (pi)->fontDescent : (pi)->ink_maxbounds.descent)
  247. #define FONT_MAX_HEIGHT(pi)    (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
  248. #define FONT_MIN_LEFT(pi)    ((pi)->ink_minbounds.leftSideBearing < 0 ? \
  249.                 (pi)->ink_minbounds.leftSideBearing : 0)
  250. #define FONT_MAX_RIGHT(pi)    ((pi)->ink_maxbounds.rightSideBearing > \
  251.                 (pi)->ink_maxbounds.characterWidth ? \
  252.                 (pi)->ink_maxbounds.rightSideBearing : \
  253.                 (pi)->ink_maxbounds.characterWidth)
  254. #define FONT_MAX_WIDTH(pi)    (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
  255.  
  256.  
  257.